#!/bin/bash
##获取git分支
function obtain_git_branch {
  br=`git branch | grep "*"`
  echo ${br/* /}
}
result=`obtain_git_branch`
dir="/data/zhongbin/apache-maven-3.8.4/bin"
command=
if [[ ! -d "$dir" ]]; then
 echo "文件夹不存在"
 command="mvn"
else
 echo "文件夹存在"
 command=$dir"/mvn"
fi
echo $command
$command clean  package assembly:assembly  -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
mkdir -p package-build/target/article/di-plugin/package/
mkdir -p package-build/target/article/di-plugin/tmp/
cp -r khaos-spark/target/plugin-dir/*   package-build/target/article/di-plugin/tmp/
cp -r sql  script   package-build/target/article/di-plugin/

if [ -d LakeHub ]; then rm -rf LakeHub; fi
git clone git@newgit.op.ksyun.com:EC/LakeHub.git
cd LakeHub
git checkout ${result}
git pull
$command clean  package assembly:assembly  -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
cd ..
cp -r LakeHub/target/syncTask2/*  package-build/target/article/di-plugin/tmp/
tar -zcvf package-build/target/article/di-plugin/package/di-plugin.tgz -C package-build/target/article/di-plugin/tmp/ .
rm -rf package-build/target/article/di-plugin/tmp/